﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

namespace Tradex.Trading {

    /// <summary>
    /// The OrderUpdate class contains ynamic aggregating information about the total execution
    /// of an order. It works together with the OrderExecution (which contains indivisual order
    /// execution information) and sums up the total of the executions.
    /// </summary>
    public class OrderUpdate {

        /// <summary>
        /// Public Constructor taking all values.
        /// </summary>
        /// <param name="timestamp"></param>
        /// <param name="status"></param>
        /// <param name="filled"></param>
        /// <param name="averagePrice"></param>
        /// <param name="unfilled"></param>
        /// <param name="message"></param>
        public OrderUpdate(
            DateTime timestamp,
            OrderStatus status,
            int filled,
            double averagePrice,
            int unfilled,
            string message
        ) {
            Timestamp = timestamp;
            Status = status;
            Filled = filled;
            AveragePrice = averagePrice;
            Unfilled = unfilled;
            Message = message;
        }

        /// <summary>
        /// Gets the Timestamp of the OrderUpdate.
        /// </summary>
        public DateTime Timestamp { get; private set; }

        /// <summary>
        /// Gets the Status of the OrderUpdate.
        /// </summary>
        public OrderStatus Status { get; private set; }

        /// <summary>
        /// Gets the number of filled items of the Order.
        /// </summary>
        public int Filled { get; private set; }

        /// <summary>
        /// Gets the average price of all executions for this order.
        /// </summary>
        public double AveragePrice { get; private set; }

        /// <summary>
        /// Gets the number of unfilled items for this Order.
        /// </summary>
        public int Unfilled { get; private set; }

        /// <summary>
        /// Gets a string message for the Order.
        /// </summary>
        public string Message { get; private set; }

        /// <inheritdoc />
        public override string ToString() {
            string retval = String.Format(
                CultureInfo.InvariantCulture, "{0} - {1} @ {2}, {3} open // {4}",
                Status, Filled, AveragePrice, Unfilled, Message
            );
            return retval;
        }

    }

}
